Allow applications to use gtk-menu-bar-accel in 3.12
authorMatthias Clasen <mclasen@redhat.com>
Mon, 23 Sep 2013 17:10:19 +0000 (13:10 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 3 Mar 2014 23:58:36 +0000 (18:58 -0500)
gnome-terminal is still using this setting, so we'll let
applications override it for another cycle. It is no longer
backed by a system-wide setting, though, and it will still
go away eventually.

This partically reverts b26c74e5dac0b5fd869d2c8cc7a0edb6b01aeebd

gtk/gtkmenubar.c
gtk/gtksettings.c

index 217308577f558363a658a69e0a0f61e439775f32..3b5f7752e76369a6a0a02c00adec13af3e4f2c24 100644 (file)
@@ -696,35 +696,54 @@ window_key_press_handler (GtkWidget   *widget,
                           GdkEventKey *event,
                           gpointer     data)
 {
+  gchar *accel = NULL;
   gboolean retval = FALSE;
-  guint keyval = GDK_KEY_F10;
 
-  /* FIXME this is wrong, needs to be in the global accel resolution
-   * thing, to properly consider i18n etc., but that probably requires
-   * AccelGroup changes etc.
-   */
-  if (event->keyval == keyval && event->state == 0)
+  g_object_get (gtk_widget_get_settings (widget),
+                "gtk-menu-bar-accel", &accel,
+                NULL);
+
+  if (accel && *accel)
     {
-      GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
-      GList *menubars;
+      guint keyval = 0;
+      GdkModifierType mods = 0;
 
-      menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
-                                            GTK_DIR_TAB_FORWARD, NULL);
-      g_list_free (tmp_menubars);
+      gtk_accelerator_parse (accel, &keyval, &mods);
 
-      if (menubars)
+      if (keyval == 0)
+        g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
+
+      /* FIXME this is wrong, needs to be in the global accel resolution
+       * thing, to properly consider i18n etc., but that probably requires
+       * AccelGroup changes etc.
+       */
+      if (event->keyval == keyval &&
+          ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
+          (mods & gtk_accelerator_get_default_mod_mask ())))
         {
-          GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
+          GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
+          GList *menubars;
 
-          _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
-          gtk_menu_shell_select_first (menu_shell, FALSE);
+          menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
+                                                GTK_DIR_TAB_FORWARD, NULL);
+          g_list_free (tmp_menubars);
 
-          g_list_free (menubars);
+          if (menubars)
+            {
+              GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
+
+              _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
+              gtk_menu_shell_select_first (menu_shell, FALSE);
+
+              g_list_free (menubars);
 
-          retval = TRUE;
+              retval = TRUE;
+            }
         }
     }
 
+  g_free (accel);
+
   return retval;
 }
 
index ebde1ef32e9a60e555b60692bc3981b414a4b900..ea043e36f855d7f96187c004e427194536970004 100644 (file)
@@ -482,14 +482,15 @@ gtk_settings_class_init (GtkSettingsClass *class)
    *
    * Keybinding to activate the menu bar.
    *
-   * Deprecated: 3.10: This setting is ignored.
+   * Deprecated: 3.10: This setting can still be used for application
+   *      overrides, but will be ignored in the future
    */
   result = settings_install_property_parser (class,
                                              g_param_spec_string ("gtk-menu-bar-accel",
                                                                   P_("Menu bar accelerator"),
                                                                   P_("Keybinding to activate the menu bar"),
                                                                   "F10",
-                                                                  GTK_PARAM_READWRITE | G_PARAM_DEPRECATED),
+                                                                  GTK_PARAM_READWRITE),
                                              NULL);
   g_assert (result == PROP_MENU_BAR_ACCEL);